import numpy as np
import matplotlib.pyplot as plt

# 折线图
def zhexiantu_one():
    x = np.arange(50)
    np.random.seed(1000)
    y = np.random.randint(20, size=(50,))
    plt.plot(x,y, '-c',lw = 3)
    plt.show()

# 柱状图
def zhuzhuangtu_one():
    # 为了显示中文，指定默认字体
    plt.rcParams['font.sans-serif'] = ['SimHei']

    # x，y 刻度规定
    plt.xlabel("时间")
    plt.ylabel("名称")
    plt.title("历史")
    hengzhou = ["1990","2000","2020"]
    shuzhou = ["张艺谋","六号村","七号村"]
    plt.bar( x = hengzhou, height = shuzhou )
    plt.show()


# 两图合并
def liangtuhebing_one():
    # 显示中文
    plt.rcParams['font.sans-serif'] = ['SimHei']

    # 第一个图 折线图
    plt.subplot(211)
    x = np.arange(10)
    np.random.seed(100)
    y = np.random.randint(50 ,size=(10,))
    plt.plot(x, y, '-r',lw = 4)

    # 第二图 柱状图
    plt.subplot(212)
    plt.xlabel("年纪")
    plt.ylabel("人数")
    plt.title("各个年级的人数")
    x = ["17","18","19"]
    y = ["1000","2000","3000"]
    plt.bar(x=x,height=y)

    plt.show()
if __name__ == '__main__':
    liangtuhebing_one()